home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-11
/
pdrd2.zip
/
RD.ZIP
/
RD_TOUR.PRG
< prev
next >
Wrap
Text File
|
1993-01-11
|
16KB
|
453 lines
/*
RD_TOUR.PRG
*/
#include "inkey.ch"
#include "read.ch"
//---------
func main()
local nTop := 3, nLeft := 0
local aMenu := {;
"Overview: What's the Get/Read Collection?",;
"The ADread() Syntax",;
"The Default Active Keys and Mouse Spots",;
"Demo: The Basic Implementation",;
"The ADread() APIs",;
"Demos: Extending Its Functionality",;
"A Quick Syntax Reference";
}
local aTrigger := { 1,14,20,11,14,22,16 }
local aBlock := {;
{|e| ADviewfile( "overview.rd" )},;
{|e| ADviewfile( "syntax.rd" )},;
{|e| ADviewfile( "keys.rd" )},;
{|e| ADviewfile( "rd_demo1.prg", {||Xdemo1()} )},;
{|e| ADviewfile( "api.rd" )},;
{|e| Xfunction(e)},;
{|e| ADviewfile( "quickref.rd" )};
}
Xintro()
ADvermenu( nTop, nLeft, aMenu, aTrigger, aBlock )
ADcredit(13,16)
setblink( .t. )
return nil
//--------------------
func Xfunction( e, cDbf )
local nTop := ADvm_row(e) + 1, nLeft := ADvm_left(e) + 4
local aMenu := {;
"Timed Out Feature",;
"Popup Picklist, Jump to any Get",;
"Hot Keys",;
"Hot Spots",;
"Reactivating an Exited Read",;
"Changing the Memoedit Attributes",;
"Key-wise Validation";
}
local xBlock := {;
{|e| ADviewfile( "rd_demo2.prg", {||Xdemo2()} )},;
{|e| ADviewfile( "rd_demo3.prg", {||Xdemo3()} )},;
{|e| ADviewfile( "rd_demo4.prg", {||Xdemo4()} )},;
{|e| ADviewfile( "rd_demo5.prg", {||Xdemo5()} )},;
{|e| ADviewfile( "rd_demo6.prg", {||Xdemo6()} )},;
{|e| ADviewfile( "rd_demo7.prg", {||Xdemo7()} )},;
{|e| ADviewfile( "rd_demo8.prg", {||Xdemo8()} )};
}
ADvermenu( nTop, nLeft, aMenu, {1,1,5,5,1,14,10}, xBlock )
return nil
//-----------------
func Xdemo1()
local getlist[0]
local cShort := "Short string"
local cLong := "This is a very long string. It is '@S PICTUREd'. This is the last of three sentences."
local nNumber := 9
local lLogical := .t.
local dDate := date()
local aArray := { "Frankie", "Library" }
local nT := 10, nL := 10, nB := 18, nR := 50
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
aScn = ADbox( nT, nL, nB, nR )
aScn2 = ADmessage( { "Choose option #3 from the main menu to get acquainted with the active",;
"keys and mouse spots." },;
20,, .f., .f. )
@nT+1, nL+2 say "Short String" adget cShort
@nT+2, nL+2 say "Long String " adget cLong picture "@S24"
@nT+3, nL+2 say "Numeric " adget nNumber
@nT+4, nL+2 say "Logical " adget lLogical
@nT+5, nL+2 say "Date " adget dDate
@nT+6, nL+2 say "Array Elem1 " adget aArray[1]
@nT+7, nL+2 say "Array Elem2 " adget aArray[2]
ADread( getlist )
ADrestscn( aScn2 )
ADrestscn( aScn )
setcolor( cColor )
return nil
//-----------
func Xdemo2()
local getlist[0]
local cShort := "Short string"
local cLong := "This is a very long string. It is '@S PICTUREd'. This is the last of three sentences."
local nNumber := 9
local lLogical := .t.
local dDate := date()
local aArray := { "Frankie", "Library" }
local nT := 10, nL := 10, nB := 18, nR := 50
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
local bConfig := {|e| ADr_timedout( e, { 3, {||ADmessage( {"Timed Out!"} )} } )}
aScn = ADbox( nT, nL, nB, nR )
aScn2 = ADmessage( { "The Read times out every 3 clock ticks of idle period" },;
20,, .f., .f. )
@nT+1, nL+2 say "Short String" adget cShort
@nT+2, nL+2 say "Long String " adget cLong picture "@S24"
@nT+3, nL+2 say "Numeric " adget nNumber
@nT+4, nL+2 say "Logical " adget lLogical
@nT+5, nL+2 say "Date " adget dDate
@nT+6, nL+2 say "Array Elem1 " adget aArray[1]
@nT+7, nL+2 say "Array Elem2 " adget aArray[2]
ADread( getlist, bConfig )
ADrestscn( aScn2 )
ADrestscn( aScn )
setcolor( cColor )
return nil
//-----------
func Xdemo3()
local aPayModes := { "Cash ",;
"Credit Card",;
"Check " }
local aCards := { "Visa ",;
"MasterCard",;
"Discover " }
local getlist[0]
local cPayMode := space(11)
local cCardType := space(10)
local cCardNumber := space(16)
local nAmount := 0
local nT := 10, nL := 10, nB := 15, nR := 42
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
local bConfig := {|e| ADr_keys( e,;
{K_ALT_F1, K_F10},;
{|e,nth,nkey| Xkeys3(e,nth,nkey,aPayModes,aCards)};
);
}
aScn = ADbox( nT, nL, nB, nR )
aScn2 = ADmessage( {;
"Popups are attached to 'Payment mode' and 'Card type'.",;
"Activate them by pressing ALT-F1 or by keying in an invalid",;
"entry.",;
"You may also press F10 to blank all Gets";
},;
18,, .f., .f.;
)
@nT+1, nL+2 say "Payment mode" adget cPayMode;
valid {|e,_x| _x := ADr_popup( e, row()+1, col()+3, aPayModes, {4,11,5} ),;
_x != 0 }
@nT+2, nL+2 say "Card type " adget cCardType;
valid {|e| ADr_popup( e, row()+1, col()+3, aCards ) > 0};
when ( cPayMode == "Credit Card" )
@nT+3, nL+2 say "Card number " adget cCardNumber;
valid {|e| ADr_required(e)};
when ( cPayMode == "Credit Card" )
@nT+4, nL+2 say "Amount " adget nAmount picture "99999.99"
ADread( getlist, bConfig )
ADrestscn( aScn2 )
ADrestscn( aScn )
setcolor( cColor )
return nil
//------------------------------------------
func Xkeys3( e, nth, nkey, aPayMode, aCards )
if nkey = K_ALT_F1
Xpopup3( e, aPayMode, aCards )
elseif nkey = K_F10
ADr_blank( e, {} )
ADr_jump( e, 1, .t. )
endif
return nil
//-------------------------------
func Xpopup3(e, aPayModes, aCards)
local nthGet := ADr_nthget(e)
if nthGet = 1
ADr_popup( e, row()+1, col()+3, aPayModes, {4,11,5}, .t. )
elseif nthGet = 2
ADr_popup( e, row()+1, col()+3, aCards,, .t. )
else
tone(100,1)
endif
return nil
//-----------
func Xdemo4()
local getlist[0]
local cShort := "Short string"
local cLong := "This is a very long string. It is '@S PICTUREd'. This is the last of three sentences."
local nNumber := 9
local lLogical := .t.
local dDate := date()
local aArray := { "Frankie", "Library" }
local nT := 2, nL := 10, nB := 10, nR := 50
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
local bConfig := {|e| ADr_keys( e, { K_F7, K_F8, K_F9, K_F10 },;
{|e,nth,nkey|Xkeys4(e,nth,nkey)};
),;
ADr_exit( e, {|e| ADr_filled( e,;
{ 1, 2, 5 },;
{|| ADmessage({ "Fields 1, 2, and 5 may not be left blank"})};
);
};
);
}
aScn = ADbox( nT, nL, nB, nR )
@nT+1, nL+2 say "Short String" adget cShort
@nT+2, nL+2 say "Long String " adget cLong picture "@S24"
@nT+3, nL+2 say "Numeric " adget nNumber
@nT+4, nL+2 say "Logical " adget lLogical
@nT+5, nL+2 say "Date " adget dDate
@nT+6, nL+2 say "Array Elem1 " adget aArray[1]
@nT+7, nL+2 say "Array Elem2 " adget aArray[2]
aScn2 = ADmessage( { "The following are hot keys:",;
" F7 - blanks the current Get",;
" F8 - blanks Get #2",;
" F9 - blanks Get #s 6 and 7",;
" F10 - blanks all Gets",;
"",;
"The Read will not be saved if any of Get #s 1, 2, or 5",;
"is empty";
}, 13,, .f., .f. )
ADread( getlist, bConfig )
ADrestscn( aScn )
ADrestscn( aScn2 )
setcolor( cColor )
return nil
//-----------------------
func Xkeys4(e, nth, nkey )
if nth = 1
ADr_blank( e )
elseif nth = 2
ADr_blank( e, 2 )
elseif nth = 3
ADr_blank( e, { 6, 7 } )
elseif nth = 4
ADr_blank( e, {} )
endif
return nil
//-----------
func Xdemo5()
local getlist[0]
local cShort := "Short string"
local cLong := "This is a very long string. It is '@S PICTUREd'. This is the last of three sentences."
local nT := 3, nL := 10, nB := 6, nR := 50
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
local bConfig := {|e| ADr_lbuttons( e,;
{ {nT-1,31,nT-1,34}, {nT-1,38,nT-1,49} },;
{|e,nth,mrow,mcol| Xbuttons5(e,nth,mrow,mcol,nB)};
);
}
aScn = ADbox( nT, nL, nB, nR )
aScn2 = ADsavescn( nT-1, nL, nT-1, nR )
setpos( nT-1, nL )
dispout( " Hot Spots --> Beep │ View Keys.Rd ", if( iscolor(), "W+/B", "N/W" ) )
@nT+1, nL+2 say "Short String" adget cShort
@nT+2, nL+2 say "Long String " adget cLong picture "@S24"
ADread( getlist, bConfig )
ADrestscn( aScn2 )
ADrestscn( aScn )
setcolor( cColor )
return nil
//--------------------------------
func Xbuttons5(e,nth,mrow,mcol,nB)
if nth = 1
tone(100,1)
elseif nth = 2
ADm_rwait()
ADviewfile( "KEYS.RD",, {nB+2} )
endif
return nil
//-----------
func Xdemo6()
local getlist[0]
local cShort := "Short string"
local cLong := "This is a very long string. It is '@S PICTUREd'. This is the last of three sentences."
local nT := 10, nL := 10, nB := 13, nR := 50
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2, aReadRetval
#define DO_NOT_KILL .f.
#define READ_ENGINE aReadRetval[1]
aScn = ADbox( nT, nL, nB, nR )
aScn2 = ADmessage( { "This example will demonstrate how to reactivate an exited Read"},;
20,, .f., .f. )
@nT+1, nL+2 say "Short String" adget cShort
@nT+2, nL+2 say "Long String " adget cLong picture "@S24"
aReadRetval = ADread( getlist,,, DO_NOT_KILL )
ADrestscn( aScn2 )
aScn = ADrestscn( aScn )
ADmessage( {;
"You have exited the Read. The Read engine, however, continues to 'live'.",;
"You may re-activate it any time you want to. In this demo, we will",;
"do that as soon as you press any key. The reactivated Read, by default,",;
"will consist of empty Gets, and Get #1 will have the initial focus. ";
},18 )
aScn = ADrestscn( aScn )
ADr_again( READ_ENGINE )
ADrestscn( aScn )
setcolor( cColor )
return nil
//-----------
func Xdemo7()
local getlist[0]
local cShort := "Short string"
local cLong := "This is a very long string. Press 'Tab' to expand it into a memoedit."
local nT := 10, nL := 10, nB := 13, nR := 50
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
local bConfig := {|e| ADr_expattr( e,;
{0,0,4,31},;
if( iscolor(), "W+/B", "W+/N" ),;
"┌─┐│┘─└│ ",;
"Esc:Exit Tab:Sauv F1:Aide";
);
}
aScn = ADbox( nT, nL, nB, nR )
aScn2 = ADmessage( { "This changes the default attributes of the expanded Get" },;
22,, .f., .f. )
@nT+1, nL+2 say "Short String" adget cShort
@nT+2, nL+2 say "Long String " adget cLong picture "@S24"
ADread( getlist, bConfig )
ADrestscn( aScn2 )
ADrestscn( aScn )
setcolor( cColor )
return nil
func Xdemo8()
local getlist[0]
local dDate := date()
local cIdNum := "A000"
local nT := 4, nL := 10, nB := 7, nR := 26
local cColor := setcolor( if( iscolor(), "W+/BG, GR+/R,,, N/R", nil ) )
local aScn, aScn2
local bConfig := {|e| ADr_keyvalid( e,{|cKey,nPos,nthGet,cBuffer| Xkeyvalid(cKey,nPos,nthGet,cBuffer)} )}
aScn = ADbox( nT, nL, nB, nR )
@nT+1, nL+2 say "Date" adget dDate
@nT+2, nL+2 say "ID #" adget cIdNum picture "!999"
aScn2 = ADmessage( { "Every key is validated. For example, you cannot enter a '3' in",;
"the Date's first position. Neither can you enter anything higher",;
"than '2' if the first is a '0'. As for ID #, you can only enter",;
"either an 'A' or a 'B' in the first position, and only digits in",;
"the other positions.";
}, 16,, .f., .f. )
ADread( getlist, bConfig )
ADrestscn( aScn2 )
ADrestscn( aScn )
setcolor( cColor )
return nil
//-------------------------------------------
func Xkeyvalid( cKey, nPos, nthGet, cBuffer )
local lValid := .t.
if nthGet = 1
if nPos = 1
if !cKey $ "01"
ADmessage( { "Only '0' and '1' are valid in the first position" } )
lValid = .f.
endif
elseif nPos = 2
if left( cBuffer, 1 ) == "0" .and. cKey == "0"
ADmessage( { "'0' is not valid in the second position" } )
lValid = .f.
elseif left( cBuffer, 1 ) == "1" .and. !cKey $ "012"
ADmessage( { "Only '0', '1' and '2' are valid in the second position" } )
lValid = .f.
endif
elseif nPos = 4
if !cKey $ "0123"
ADmessage( { "Only '0', '1', '2', and '3' are valid in the 4th position" } )
lValid = .f.
endif
elseif nPos = 5
if substr( cBuffer, 4, 1 ) == "3" .and. !cKey $ "01"
ADmessage( { "'0' and '1' are valid in the 5th position" } )
lValid = .f.
endif
elseif nPos = 7
if cKey != "9"
ADmessage( { "Only '9' is valid in the 7th position" } )
lValid = .f.
endif
elseif nPos = 8
if !cKey $ "0123"
ADmessage( { "Only '0', '1', '2', and '3' are valid in the last position" } )
lValid = .f.
endif
endif
elseif nthGet = 2
if nPos = 1
if !cKey $ "ABab"
ADmessage( { "Only 'A' and 'B' are valid in the first position" } )
lValid = .f.
endif
else
if !cKey $ "0123456789"
ADmessage( { "Only digits are valid in the 2nd to the last positions" } )
lValid = .f.
endif
endif
endif
return lValid
//-----------
func Xintro()
cls
ADmessage( {;
"The Get/Read Collection of the Frankie Library",;
"Version 1.02",;
"A Mouseable and Extensible Read Engine and APIs",;
"═══════════════════════════════════════════════",;
"",;
"Copyright (c) The Programmer's Desk, 1992, 1993",;
"Press any key";
}, 7, 10, .f. )
ADxwait()
return nil